package org.ucas.kgraph.utils.exception;

import org.springframework.http.HttpStatus;
import org.ucas.kgraph.utils.constants.ErrCode;

/**
 * 主要负责冲突类型的异常,比如已占用的邮箱等
 * @author suemi
 */
public class ConflictException extends RestException {

  public static ConflictException Term_Conflict = new ConflictException(ErrCode.TERM_CONFLICT);
  public static ConflictException User_Confilict = new ConflictException(ErrCode.USER_CONFLICT);
  public static ConflictException Com_Confilict = new ConflictException(ErrCode.COM_CONFLICT);
  public static ConflictException Relation_Confilict = new ConflictException(ErrCode.RELATION_CONFLICT);
  public static ConflictException Role_Conflict = new ConflictException(ErrCode.ROLE_CONFLICT);

  private ConflictException(ErrCode errCode) {
    super(errCode);
  }

  public static ConflictException of(String msg) {
    return new ConflictException(new ErrCode(
            HttpStatus.CONFLICT, msg));
  }
}
